﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace KhaoSatSinhVienTotNghiep.Model
{
   public partial class DanhSachTraLoi
    {
       private static KhaoSatSVTNDataContext context = new KhaoSatSVTNDataContext();


       public static List<DSTL> GetAll()
       {
           return context.DSTLs.ToList(); ;
       }

       public static bool AddNew(DSTL ds)
       {
           if (CheckExist(ds.MaDSKhaoSat, ds.MaCauTL) == true)
               return false;
           else 
           {
               context.DSTLs.InsertOnSubmit(ds);
               context.SubmitChanges();
               return true;
           }
       }

       public static bool CheckExist(int mads, int macautl)
       {
           var result = context.DSTLs.Where(dstl => dstl.MaCauTL == macautl && dstl.MaDSKhaoSat == mads);
           if (result.Count() > 0)
               return true;
           return false;
       }
    }
}
